package com.smh.a04objectStreamDemo1;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;

public class ObjectStreamDemo2 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        //反序列化流
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("day27-code\\file\\demo2\\a.txt"));

        Object o = ois.readObject();
        if (o instanceof Student s) {
            System.out.println(s);
        }
        System.out.println(o);
        ois.close();
        //如果你修改了bean对象,那么反序列的结果会报错
        //解决,固定版本号
        //输出结果没有gender是因为tostring方法没有重写

        //序列化文件只要改了,即使改回来,文件反序列化时也会报错


    }
}
